<?php

$this->widget('ext.Truulo.TruuloModuleSearch', array(
    'model' => $model,
    'grid_id' => $grupo->id . '_grid',
    'id' => 'form_' . $grupo->id,
    'nameInput' => 'input_' . $grupo->id,
    'idList' => 'sel_' . $grupo->id
        )
);

$this->widget('ext.selgridview.BootSelGridView', array(
    'id' => $grupo->id . '_grid',
    'type' => 'striped bordered hover advance',
    "template" => "{items}{summary}{pager}",
    'dataProvider' => $model->activos()->searchByGroup($ids),
    'afterAjaxUpdate' => 'function(id,data){ $(\'span.star-rating > input\').rating(); $(\'div .rating-cancel\').hide(); ratingCargaGrid();}',
    'selectableRows' => 2,
    'columns' => array(
        array(
            'class' => 'CCheckBoxColumn',
        ),
        array(
            'name' => 'rating',
            'type' => 'raw',
            'value' => '$this->grid->controller->widget("CStarRating", array (
                        "name" => $this->id."_".$data->id,
                        "id" => "rating_".$this->id."_".$data->id,
                        "value" => $data->rating,
                        "allowEmpty" => false,
                        "maxRating" => 5,
                        "htmlOptions" => array("class"=>"star-rating"),
                        "callback"=>"js:function(){
                            ratingGrupo(\"$this->id\",\"$data->id\");
                        }"
                    ), true)',
            'headerHtmlOptions' => array('style' => 'width:85px;'),
            'filter' => false,
            'sortable' => true,
            'header' => '<i class="icon-star"></i><i class="icon-star"></i><i class="icon-star"></i><i class="icon-star"></i><i class="icon-star"></i>'
        ),
        array(
            'name' => 'nombre',
            'value' => 'CHtml::link($data->nombre, Yii::app()->createUrl("crm/cuenta/view",array("id"=>$data->id)))',
            'type' => 'raw',
        ),
        array(
            'header' => 'Teléfono',
            'value' => '$data->telefonoPrincipal?$data->telefonoPrincipal:"<label class=\"text-info\">no registrado</label>"',
            'type' => 'raw',
        ),
        array(
            'name' => 'industria_id',
            'value' => '$data->industria?$data->industria->nombre:null',
        ),
        array(
            'name' => 'tipo',
            'value' => '$data->tipoTexto',
            'filter' => $model->tipoOpciones,
        ),
        array(
            'name' => 'owner_id',
            'value' => 'Yii::app()->user->um->loadUserById($data->owner_id)->username',
        ),
        array(
            'class' => 'CButtonColumn',
            'template' => '{update} {delete}',
            'buttons' => array(
                'update' => array(
                    'label' => '<button class="btn btn-primary"><i class="icon-pencil"></i></button>',
                    'options' => array('title' => 'Actualizar'),
                    'imageUrl' => false,
                ),
                'delete' => array(
                    'label' => '<button class="btn btn-danger"><i class="icon-trash"></i></button>',
                    'options' => array('title' => 'Eliminar'),
                    'imageUrl' => false,
                ),
            ),
            'htmlOptions' => array(
                'width' => '80px'
            )
        ),
    ),
));
?>
<form id="<?php echo $grupo->id.'_form' ?>" method="get" target="blank">
    <input type="hidden"  name="grupo_id" value="<?php echo $grupo->id ?>">
</form>